from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.future import Engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine

from core.config import settings


async def get_sync_engine() -> Engine:
    return create_engine(settings.SYNC_DATABASE_URI, echo=settings.DEBUG, future=True)

# engine = create_async_engine(r'sqlite+aiosqlite:///C:\Users\admin\PycharmProjects\lct-krasnodar-2023\temp.db', echo=settings.DEBUG)
engine = create_async_engine(f"mysql+asyncmy://{settings.DATABASE_USER}:"
                             f"{settings.DATABASE_PASSWORD}@"
                             f"{settings.DATABASE_HOST}:"
                             f"{settings.DATABASE_PORT}"
                             f"/{settings.DATABASE_NAME}", echo=settings.DEBUG)
SessionLocal = sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
